package com.guigu.qingcheng.servicegoods.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GoodsSenderConfig {
    @Bean
    public Queue queue_sms () {
        return new Queue("queue.back");
    }

    //创建上架广播模式
    @Bean
    public FanoutExchange fanoutExchangesj (){
        return new FanoutExchange("exchange.sj");
    }

    //创建下架广播模式
    @Bean
    public FanoutExchange fanoutExchangexj (){
        return new FanoutExchange("exchange.xj");
    }

    @Bean
    public Queue queue_sjym () {
        return new Queue("queue.sjym");
    }

    @Bean
    public Queue queue_xjym () {
        return new Queue("queue.xjym");
    }

    @Bean
    public Queue queue_sjsy () {
        return new Queue("queue.sjsy");
    }

    @Bean
    public Queue queue_xjsy () {
        return new Queue("queue.xjsy");
    }

    //上架交换机绑定
    @Bean
    public Binding binding1(@Qualifier("queue_sjym")Queue a,FanoutExchange fanoutExchangesj){
        return BindingBuilder.bind(a).to(fanoutExchangesj);
    }

    @Bean
    public Binding binding2(@Qualifier("queue_sjsy")Queue b,FanoutExchange fanoutExchangesj){
        return BindingBuilder.bind(b).to(fanoutExchangesj);
    }

    //下架交换机绑定
    @Bean
    public Binding binding3(@Qualifier("queue_xjym")Queue c,FanoutExchange fanoutExchangexj){
        return BindingBuilder.bind(c).to(fanoutExchangexj);
    }

    @Bean
    public Binding binding4(@Qualifier("queue_xjsy")Queue d,FanoutExchange fanoutExchangexj){
        return BindingBuilder.bind(d).to(fanoutExchangexj);
    }

}
